<?php
$host = $_SERVER['HTTP_HOST'];

function parseImgUrl($imgName) {
    global $host;
    return 'http://' . $host . '/files/' . $imgName;
}

const CACHE_FILE = __DIR__.'/temp.txt';
function saveCache($arr) {
    file_put_contents(CACHE_FILE, serialize($arr));
}

function readCache() {
    if(!file_exists(CACHE_FILE)) return [];

    $handle = fopen(CACHE_FILE, "r");
    $content = fread($handle, filesize(CACHE_FILE));
    return unserialize($content);
}

